﻿using SwitData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    // NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
    public class SwitchWCF : SwitchService
    {
        public List<PortableSwitch> GetSwitchList()
        {
            SwitchRepository sr = new SwitchRepository();
            return PortableSwitch.TranslateSwitchEntityListToPortableSwitchList(sr.GetSwitchList());
        }

        public List<PortableSwitchType> GetSwitchTypes()
        {
            SwitchRepository sr = new SwitchRepository();
            return PortableSwitchType.TranslateSwitchEntityListToSwitchTypeList(sr.GetSwitchTypeList());
        }

        public PortableSwitch GetSwitch(int id)
        {
            SwitchRepository sr = new SwitchRepository();
            var eSwitch = sr.GetSwitch(id);
            if (eSwitch == null)
                return null;
            return PortableSwitch.TranslateSwitchEntityToPortableSwitch(eSwitch);
        }

        public void AddSwitch(PortableSwitch pSwitch)
        {
            SwitchRepository sr = new SwitchRepository();
            var eSwitch = PortableSwitch.TranslatePortableSwitchtoSwitchEntity(pSwitch);
            sr.AddSwitch(eSwitch);
        }

        public void DeleteSwitch(int ID)
        {
            SwitchRepository sr = new SwitchRepository();
            sr.DeleteSwitch(ID);
        }

        public void EditSwitch(int ID)
        {
            SwitchRepository sr = new SwitchRepository();
            var eSwtich = sr.GetSwitch(ID);
            
        }

        
    }
}
